﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using QuanLyShop.DTO;
using QuanLyShop.BUS;

namespace SHOP
{
    public partial class TL_QL_DanhMuc_ThemLoaiMatHang : Form
    {
        public TL_QL_DanhMuc_ThemLoaiMatHang()
        {
            InitializeComponent();
        }

        private void bntThem_Click(object sender, EventArgs e)
        {
            MatHangBUS BUS = new MatHangBUS();

            string TenMatHang = tbTenLoaiSanPham.Text;
            string ThongTinThem = tbThongTinThem.Text;

            if (TenMatHang.Equals("") || ThongTinThem.Equals(""))
            {
                MessageBox.Show("Vui lòng nhập đầy đủ thông tin");
            }
            string MaMatHang = BUS.MaTangTuDong();

            MatHangDTO mh = new MatHangDTO();
            mh.ID_MatHang = MaMatHang;
            mh.TenMatHang = TenMatHang;
            mh.ThongTinThem = ThongTinThem;
            mh.TinhTrang = 0;
            int kq = BUS.ThemMatHang(mh);
            if (kq == 1)
            {
                MessageBox.Show("Thêm Thành Công");
                TL_QL_DanhMuc frmQuanLyDanhMuc = new TL_QL_DanhMuc();
                frmQuanLyDanhMuc.ShowDialog();
                this.Close();
            }
            else
            {
                MessageBox.Show("Thêm Không Thành Công");
            }

        }

        private void btnHuy_Click(object sender, EventArgs e)
        {
            this.Close();
        }
    }
}
